
<!DOCTYPE html>
<html lang='zh-cn'>
<head>
  <meta charset='utf-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <title>所有项目 - 禅道</title>
  <script>window.config={"webRoot":"\/zentao\/","debug":false,"appName":"","cookieLife":30,"requestType":"PATH_INFO","requestFix":"-","moduleVar":"m","methodVar":"f","viewVar":"t","defaultView":"html","themeRoot":"\/zentao\/theme\/","currentModule":"project","currentMethod":"all","clientLang":"zh-cn","requiredFields":"","router":"\/zentao\/index.php","save":"\u4fdd\u5b58","runMode":"","timeout":30000,"pingInterval":""};
  window.lang={"submitting":"\u7a0d\u5019...","save":"\u4fdd\u5b58","expand":"\u5c55\u5f00\u5168\u90e8","timeout":"\u8fde\u63a5\u8d85\u65f6\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\u73af\u5883\uff0c\u6216\u91cd\u8bd5\uff01"};

  </script>
  <script>config.onlybody = "no";</script><link rel='stylesheet' href='/zentao/theme/default/zh-cn.default.css?v=12.5.3' type='text/css' media='screen' />
  <script src='/zentao/js/all.js?v=12.5.3'></script>
  <style>.mgr-5px{margin-right:5px;}
  #productsBox .col-sm-3{margin-bottom:5px;}
  #productsBox .input-group {table-layout: fixed; width: 100%;}
  #productsBox .has-branch select {width: 100%; display: table-cell; border-radius: 0 2px 2px 0; border-left: none;}
  #productsBox .has-branch select:focus {box-shadow: inset 1px 0 #4d90fe}
  #productsBox .input-group-addon {display: none;}
  #productsBox .input-group.has-branch > select[name*="product"] + .chosen-container {width: 60%!important;}
  #productsBox .input-group.has-branch > select[name*="branch"] + .chosen-container {width: 40%!important;}
  #productsBox .input-group.has-branch > select[name*="product"] + .chosen-container .chosen-single {border-radius: 2px 0 0 2px;}
  #productsBox .input-group.has-branch > select[name*="branch"] + .chosen-container .chosen-single {border-radius: 0 2px 2px 0; border-left-width: 0; padding-left: 9px;}
  #productsBox .input-group.has-branch > select[name*="branch"] + .chosen-container.chosen-container-active  .chosen-single {border-left-width: 1px; padding-left: 8px;}

  .table-children {border-left: 2px solid #cbd0db; border-right: 2px solid #cbd0db;}
  .table tbody > tr.table-children.table-child-top {border-top: 2px solid #cbd0db;}
  .table tbody > tr.table-children.table-child-bottom {border-bottom: 2px solid #cbd0db;}
  .table td.has-child > a:not(.task-toggle) {max-width: 90%; max-width: calc(100% - 30px); display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
  .table td.has-child > .task-toggle {color: #838a9d; position: relative; top: 1px; line-height: 16px;}
  .table td.has-child > .task-toggle:hover {color: #006af1; cursor: pointer;}
  .table td.has-child > .task-toggle > .icon {font-size: 16px; display: inline-block; transition: transform .2s; -ms-transform:rotate(-90deg); -moz-transform:rotate(-90deg); -o-transform:rotate(-90deg); -webkit-transform:rotate(-90deg); transform: rotate(-90deg);}
  .table td.has-child > .task-toggle > .icon:before {text-align: left;}
  .table td.has-child > .task-toggle.collapsed {top: 2px}
  .table td.has-child > .task-toggle.collapsed > .icon {-ms-transform:rotate(90deg); -moz-transform:rotate(90deg); -o-transform:rotate(90deg); -webkit-transform:rotate(90deg); transform: rotate(90deg);}
  .main-table tbody > tr.table-children > td:first-child::before {width: 3px;}
  @-moz-document url-prefix() {.main-table tbody > tr.table-children > td:first-child::before {width: 4px;}}

  .chosen-container-single .chosen-single > span{max-width: 300px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;}

  #whitelistBox .checkbox-inline, #whitelistBox .radio-inline{margin-left: 10px; display: inline-block; padding-left: 0px; padding-right: 10px;}
  .main-table > .table-responsive {padding: 0 1px; background: #fff;}
  #product_chosen .chosen-single{width:180px;}
  .thWidth{width:90px !important;}
  </style><link rel='icon' href='/zentao/favicon.ico' type='image/x-icon' />
  <link rel='shortcut icon' href='/zentao/favicon.ico' type='image/x-icon' />
  <!--[if lt IE 10]>
  <script src='/zentao/js/jquery/placeholder/min.js?v=12.5.3'></script>
  <![endif]-->
</head>
<body>
<style>
  .picker-single .picker-selection-remove{z-index: 1000;}
  .picker-selection-single:after, .picker-multi.picker-focus .picker-selections:before{font-family: ZentaoIcon !important; content: '\f0d7' !important;}
</style>
<script>
  var chooseUsersToMail = '选择要发信通知的用户...';
  if($.fn.picker)
  {
    $(document).ready(function()
    {
      $(".picker-select[data-pickertype!='remote']").picker({chosenMode: true});
      $("[data-pickertype='remote']").each(function()
      {
        var pickerremote = $(this).attr('data-pickerremote');
        $(this).picker({chosenMode: true, remote: pickerremote});
      })
    });
  }
</script>
<header id='header'>
  <div id='mainHeader'>
    <div class='container'>
      <hgroup id='heading'>
        <h1 id='companyname' title='易软天创'><a href='/temp/index' >易软天创</a>
        </h1>
      </hgroup>
      <nav id='navbar'><ul class='nav nav-default'>
        <li  data-id='my'><a href="/index/ind2" ><span> 我的地盘</span></a></li>
        <li  data-id='product'><a href='/temp/product-index-no' >产品</a></li>
        <li class='active' data-id='project'><a href='/temp/project-index-no' class='active'>项目</a></li>
        <li  data-id='qa'><a href='/temp/product-showErrorNone-qa' >测试</a></li>
        <li class='divider'></li><li  data-id='ci'><a href='/temp/repo-browse' >集成</a></li>
        <li  data-id='doc'><a href='/temp/doc' >文档</a></li>
        <li  data-id='report'><a href='/temp/report-productSummary' >统计</a></li>
        <li class='divider'></li><li  data-id='company'><a href='/temp/company-browse' >组织</a></li>
        <li  data-id='admin'><a href='/temp/admin' >后台</a></li>
      </ul>
      </nav>
      <div id='toolbar'>
        <div id="userMenu">
          <div id='searchbox'><div class='input-group'><div class='input-group-btn'><a data-toggle='dropdown' class='btn btn-link'><span id='searchTypeName'>项目</span> <span class='caret'></span></a><input type='hidden' name='searchType' id='searchType' value='project'  />
            <ul id='searchTypeMenu' class='dropdown-menu'><li ><a href='javascript:$.setSearchType("bug");' data-value='bug'>Bug</a></li><li ><a href='javascript:$.setSearchType("story");' data-value='story'>需求</a></li><li ><a href='javascript:$.setSearchType("task");' data-value='task'>任务</a></li><li ><a href='javascript:$.setSearchType("testcase");' data-value='testcase'>用例</a></li><li class='selected'><a href='javascript:$.setSearchType("project");' data-value='project'>项目</a></li><li ><a href='javascript:$.setSearchType("product");' data-value='product'>产品</a></li><li ><a href='javascript:$.setSearchType("user");' data-value='user'>用户</a></li><li ><a href='javascript:$.setSearchType("build");' data-value='build'>版本</a></li><li ><a href='javascript:$.setSearchType("release");' data-value='release'>发布</a></li><li ><a href='javascript:$.setSearchType("productplan");' data-value='productplan'>产品计划</a></li><li ><a href='javascript:$.setSearchType("testtask");' data-value='testtask'>测试单</a></li><li ><a href='javascript:$.setSearchType("doc");' data-value='doc'>文档</a></li><li ><a href='javascript:$.setSearchType("caselib");' data-value='caselib'>用例库</a></li><li ><a href='javascript:$.setSearchType("testreport");' data-value='testreport'>测试报告</a></li></ul></div><input id='searchInput' class='form-control search-input' type='search' onclick='this.value=""' onkeydown='if(event.keyCode==13) $.gotoObject();' placeholder='编号(ctrl+g)'/></div><a href='javascript:$.gotoObject();' class='btn btn-link' id='searchGo'>GO!</a></div>
          <ul id="userNav" class="nav nav-default">
            <li><a class='dropdown-toggle' data-toggle='dropdown'><span class='user-name'>admin</span><span class='caret'></span></a><ul class='dropdown-menu pull-right'><li class="user-profile-item"><a href='/temp/my-profile' class=' no-role'><div class='avatar avatar bg-secondary avatar-circle'>A</div>
              <div class="user-profile-name">admin</div><div class="user-profile-role"></div></a></li><li class="divider"></li><li><a href='/temp/my-profile' >个人档案</a>
            </li><li><a href='/temp/my-changepassword' class='iframe' data-width='500'>更改密码</a>
            </li><li class='divider'></li><li class='dropdown-submenu'><a href='javascript:;'>主题</a><ul class='dropdown-menu pull-left'><li class='selected'><a href='javascript:selectTheme("default");' data-value='default'>禅道蓝（默认）</a></li><li ><a href='javascript:selectTheme("green");' data-value='green'>叶兰绿</a></li><li ><a href='javascript:selectTheme("red");' data-value='red'>赤诚红</a></li><li ><a href='javascript:selectTheme("purple");' data-value='purple'>玉烟紫</a></li><li ><a href='javascript:selectTheme("pink");' data-value='pink'>芙蕖粉</a></li><li ><a href='javascript:selectTheme("blackberry");' data-value='blackberry'>露莓黑</a></li><li ><a href='javascript:selectTheme("classic");' data-value='classic'>经典蓝</a></li></ul></li><li class='dropdown-submenu'><a href='javascript:;'>Language</a><ul class='dropdown-menu pull-left'><li class='selected'><a href='javascript:selectLang("zh-cn");'>简体</a></li><li ><a href='javascript:selectLang("zh-tw");'>繁體</a></li><li ><a href='javascript:selectLang("en");'>English</a></li><li ><a href='javascript:selectLang("de");'>Deutsch</a></li><li ><a href='javascript:selectLang("fr");'>Français</a></li><li ><a href='javascript:selectLang("vi");'>Tiếng Việt</a></li><li ><a href='javascript:selectLang("ja");'>日本語</a></li></ul></li><li class='custom-item'><a href='custom-ajaxMenu-project-index.html?onlybody=yes' data-toggle='modal' data-type='iframe' data-icon='cog' data-width='80%'>自定义导航</a></li><li class="divider"></li><li class='dropdown-submenu'><a data-toggle='dropdown'>帮助</a><ul class='dropdown-menu pull-left'><li><a href='tutorial-start.html' class='iframe' data-class-name='modal-inverse' data-width='800' data-headerless='true' data-backdrop='true' data-keyboard='true'>新手教程</a>
            </li><li><a href='https://www.zentao.net/book/zentaopmshelp.html?fullScreen=zentao' class='open-help-tab' target='_blank' rel='noopener noreferrer'>手册</a>
            </li><li><a href='/temp/misc-changeLog' class='iframe' data-width='800' data-headerless='true' data-backdrop='true' data-keyboard='true'>修改日志</a>
            </li></ul></li>
              <li><a href='/temp/misc-about' class='about iframe' data-width='1050' data-headerless='true' data-backdrop='true' data-keyboard='true' data-class='modal-about'>关于禅道</a>
              </li><li class="divider"></li><li><a href='/temp/user-logout' >退出</a>
              </li></ul></li>
          </ul>
        </div>
      </div>
    </div>
  </div>
  <div id='subHeader'>
    <div class='container'>
      <div id="pageNav" class='btn-toolbar'><div class="btn-group angle-btn"><div class="btn-group"><button data-toggle="dropdown" type="button" class="btn">所有项目 <span class="caret"></span></button><ul class="dropdown-menu"><li><a href='/zentao/project-index-no.html' ><i class="icon icon-home"></i> 项目主页</a>
      </li><li><a href='/zentao/project-all-all.html' ><i class="icon icon-cards-view"></i> 所有项目</a>
      </li><li><a href='/zentao/project-create.html' ><i class="icon icon-plus"></i> 添加项目</a>
      </li></ul></div></div><div class='btn-group angle-btn'><div class='btn-group'><button data-toggle='dropdown' type='button' class='btn btn-limit' id='currentItem' title='测试项目'>测试项目 <span class='caret'></span></button><div id='dropMenu' class='dropdown-menu search-list' data-ride='searchList' data-url='/zentao/project-ajaxGetDropMenu-1-project-all-.html'><div class="input-control search-box has-icon-left has-icon-right search-example"><input type="search" class="form-control search-input" /><label class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label><a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a></div></div></div></div></div>
      <nav id='subNavbar'><ul class='nav nav-default'>
        <li class=' ' data-id='task'><a href='/zentao/project-task-1.html' >任务</a>
        </li>
        <li class=' ' data-id='kanban'><a href='/zentao/project-kanban-1.html' >看板</a>
        </li>
        <li class=' ' data-id='burn'><a href='/zentao/project-burn-1.html' >燃尽图</a>
        </li>
        <li class='dropdown dropdown-hover ' data-id='list'><a href='/zentao/project-grouptask-1.html' >更多<span class='caret'></span></a>
          <ul class='dropdown-menu'><li class='' data-id='groupTask'><a href='/zentao/project-groupTask-1.html' >分组视图</a>
          </li><li class='' data-id='tree'><a href='/zentao/project-tree-1.html' >树状图</a>
          </li></ul></li>
        <li class='divider'></li><li class=' ' data-id='story'><a href='/zentao/project-story-1.html' >需求</a>
      </li>
        <li class='dropdown dropdown-hover ' data-id='qa'><a href='/zentao/project-bug-1.html' >测试<span class='caret'></span></a>
          <ul class='dropdown-menu'><li class='' data-id='bug'><a href='/zentao/project-bug-1.html' >Bug</a>
          </li><li class='' data-id='build'><a href='/zentao/project-build-1.html' >版本</a>
          </li><li class='' data-id='testtask'><a href='/zentao/project-testtask-1.html' >测试单</a>
          </li></ul></li>
        <li class=' ' data-id='doc'><a href='/zentao/doc-objectLibs-project-1-project.html' >文档</a>
        </li>
        <li class='divider'></li><li class=' ' data-id='team'><a href='/zentao/project-team-1.html' >团队</a>
      </li>
        <li class='dropdown dropdown-hover ' data-id='action'><a href='/zentao/project-dynamic-1.html' >动态</a>
        </li>
        <li class='divider'></li><li class=' ' data-id='product'><a href='/zentao/project-manageproducts-1.html' >产品</a>
      </li>
        <li class=' ' data-id='view'><a href='/zentao/project-view-1.html' >概况</a>
        </li>
      </ul>
      </nav>
      <div id="pageActions"><div class='btn-toolbar'></div></div>
    </div>
  </div>
</header>

<main id='main'  >
  <div class='container'>
    <style>
      tbody.sortable > tr.drag-shadow {display: none}
      tbody.sortable > tr > td.sort-handler {cursor: move; color: #999;}
      tbody.sortable > tr > td.sort-handler > i {position: relative; top: 2px}
      tbody.sortable-sorting > tr {transition: all .2s; position: relative; z-index: 5; opacity: .3;}
      tbody.sortable-sorting {cursor: move;}
      tbody.sortable-sorting > tr.drag-row {opacity: 1; z-index: 10; box-shadow: 0 2px 4px red}
      tbody.sortable-sorting > tr.drag-row + tr > td {box-shadow: inset 0 4px 2px rgba(0,0,0,.2)}
      tbody.sortable-sorting > tr.drag-row > td {background-color: #E9F2FB!important}
      tbody.sortable > tr.drop-success > td {background-color: #cfe0ff; transition: background-color 2s;}
    </style>
    <script>
      $(document).ready(function()
      {
        $('.sortable:not(tbody)').sortable();
        $('tbody.sortable').each(function()
        {
          var $tbody = $(this);
          $tbody.sortable(
                  {
                    selector: 'tr',
                    dragCssClass: 'drag-row',
                    trigger: $tbody.find('.sort-handler').length ? '.sort-handler' : null,
                    finish: function(e)
                    {
                      var orders = {};
                      e.list.each(function()
                      {
                        orders[$(this.item).data('id')] = this.order;
                      });
                      e.orders = orders;
                      $tbody.trigger('sort.sortable', e);
                      var $thead = $tbody.closest('table').children('thead');
                      $thead.find('.headerSortDown, .headerSortUp').removeClass('headerSortDown headerSortUp').addClass('header');
                      $thead.find('th.sort-default .header').removeClass('header').addClass('headerSortDown');
                      e.element.addClass('drop-success');
                      setTimeout(function(){e.element.removeClass('drop-success');}, 800)
                    }
                  });
        });
      });
    </script>
    <div id='mainMenu' class='clearfix'>
      <div class='btn-toolbar pull-left'>
        <a href='/zentao/project-all-all-1-order_desc-0.html' class='btn btn-link' id='allTab'><span class='text'>所有</span></a>
        <a href='/zentao/project-all-undone-1-order_desc-0.html' class='btn btn-link' id='undoneTab'><span class='text'>未完成</span></a>
        <a href='/zentao/project-all-wait-1-order_desc-0.html' class='btn btn-link' id='waitTab'><span class='text'>未开始</span></a>
        <a href='/zentao/project-all-doing-1-order_desc-0.html' class='btn btn-link' id='doingTab'><span class='text'>进行中</span></a>
        <a href='/zentao/project-all-suspended-1-order_desc-0.html' class='btn btn-link' id='suspendedTab'><span class='text'>已挂起</span></a>
        <a href='/zentao/project-all-closed-1-order_desc-0.html' class='btn btn-link' id='closedTab'><span class='text'>已关闭</span></a>
        <div class='input-control space w-180px'>
          <select name='product' id='product' class='chosen form-control' onchange='byProduct(this.value, 1, "all")'>
            <option value='0' selected='selected' title='请选择产品' data-keys='qingxuanzechanpin qxzcp'>请选择产品</option>
          </select>
        </div>
      </div>
      <div class='btn-toolbar pull-right'>
        <a href='/zentao/project-export-all-0-order_desc.html' class='btn btn-link export'><i class='icon-export muted'> </i>导出</a>
        <a href='/zentao/project-create.html' class='btn btn-primary'><i class='icon-plus'></i> 添加项目</a>
      </div>
    </div>
    <div id='mainContent'>
      <form class='main-table' id='projectsForm' method='post' action='/zentao/project-batchEdit-1.html' data-ride='table'>
        <table class='table has-sort-head table-fixed' id='projectList'>
          <thead>
          <tr>
            <th class='c-id'>
              <div class="checkbox-primary check-all" title="全选">
                <label></label>
              </div>
              <a href='/zentao/project-all-all-1-id_asc-0-1-10-1.html' class='header'>ID</a>
            </th>
            <th><a href='/zentao/project-all-all-1-name_asc-0-1-10-1.html' class='header'>项目名称</a>
            </th>
            <th class='w-150px'><a href='/zentao/project-all-all-1-code_asc-0-1-10-1.html' class='header'>项目代号</a>
            </th>
            <th class='thWidth'><a href='/zentao/project-all-all-1-PM_asc-0-1-10-1.html' class='header'>项目负责人</a>
            </th>
            <th class='w-90px'><a href='/zentao/project-all-all-1-end_asc-0-1-10-1.html' class='header'>截止日期</a>
            </th>
            <th class='w-90px'><a href='/zentao/project-all-all-1-status_asc-0-1-10-1.html' class='header'>项目状态</a>
            </th>
            <th class='w-70px'>预计</th>
            <th class='w-70px'>消耗</th>
            <th class='w-70px'>剩余</th>
            <th class='w-150px'>进度</th>
            <th class='w-100px'>燃尽图</th>
            <th class='w-60px sort-default'><a href='/zentao/project-all-all-1-order_asc-0-1-10-1.html' class='sort-down'>排序</a>
            </th>
          </tr>
          </thead>
          <tbody class='sortable' id='projectTableList'>
          <tr data-id='1' data-order='5'>
            <td class='c-id'>
              <div class="checkbox-primary">
                <input type='checkbox' name='projectIDList[1]' value='1' />
                <label></label>
              </div>
              001          </td>
            <td class='text-left' title='测试项目'>
              <a href='/zentao/project-view-1.html' >测试项目</a>
            </td>
            <td class='text-left' title="9527">9527</td>
            <td></td>
            <td>2021-07-16</td>
            <td class='c-status' title='未开始'>
              <span class="status-project status-wait">未开始</span>
            </td>
            <td>0</td>
            <td>0</td>
            <td>0</td>
            <td class="c-progress">
              <div class="progress progress-text-left">
                <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                  <span class="progress-text">0%</span>
                </div>
              </div>
            </td>
            <td id='spark-1' class='sparkline text-left no-padding' values=''></td>
            <td class='sort-handler'><i class="icon icon-move"></i></td>
          </tr>
          </tbody>
        </table>
        <div class='table-footer'>
          <div class="checkbox-primary check-all"><label>全选</label></div>
          <div class="table-actions btn-toolbar"> <button type='submit' id='submit' class='btn'  data-loading='稍候...'>批量编辑</button></div>
          <ul class='pager' data-page-cookie='pagerProjectAll' data-ride='pager' data-rec-total='1' data-rec-per-page='10' data-page='1' data-link-creator='/zentao/project-all-all-0-order_desc-0-1-{recPerPage}-{page}.html'></ul>    </div>
      </form>
    </div>
    <script>$("#allTab").addClass('btn-active-text');</script>
    <script>orderBy = "order_desc";</script>
  </div><script>
  $.initSidebar();
</script>

  <iframe frameborder='0' name='hiddenwin' id='hiddenwin' scrolling='no' class='debugwin hidden'></iframe>

</main><footer id='footer'>
  <div class="container">
    <ul class='breadcrumb'><li><a href='/zentao/my/' >禅道</a>
    </li><li><a href='/zentao/project/' >项目</a>
    </li><li class='active'>所有项目</li></ul>    <div id='poweredBy'>
    <small class='muted'><a href='https://api.zentao.net/goto.php?item=aiux' class='link-aiux' target='_blank'>Designed by <strong>艾体验</strong></a></small> &nbsp;
    <a href='https://www.zentao.net' target='_blank'><i class='icon-zentao'></i> 禅道12.5.3</a> &nbsp;
    <a href='https://api.zentao.net/goto.php?item=proversion&from=footer' target='_blank' id='proLink' class='text-important'>专业版 <i class='text-danger icon-pro-version'></i></a> &nbsp;           </div>
  </div>
</footer>
<div id="noticeBox"></div>
<script>
  /* Alert got messages. */
  needPing = false;
  $(function()
  {
    var windowBlur = false;
    if(window.Notification)
    {
      window.onblur  = function(){windowBlur = true;}
      window.onfocus = function(){windowBlur = false;}
    }
    setInterval(function()
    {
      $.get(createLink('message', 'ajaxGetMessage', "windowBlur=" + (windowBlur ? '1' : '0')), function(data)
      {
        if(!windowBlur)
        {
          $('#noticeBox').append(data);
          adjustNoticePosition();
        }
        else
        {
          if(data)
          {
            if(typeof data == 'string') data = $.parseJSON(data);
            if(typeof data.message == 'string') notifyMessage(data);
          }
        }
      });
    }, 300000);
  })

</script>

<script>function setWhite(acl)
{
  acl == 'custom' ? $('#whitelistBox').removeClass('hidden') : $('#whitelistBox').addClass('hidden');
}

function switchStatus(projectID, status)
{
  if(status) location.href = createLink('project', 'task', 'project=' + projectID + '&type=' + status);
}

function switchGroup(projectID, groupBy)
{
  link = createLink('project', 'groupTask', 'project=' + projectID + '&groupBy=' + groupBy);
  location.href=link;
}

/**
 * Convert a date string like 2011-11-11 to date object in js.
 *
 * @param  string $date
 * @access public
 * @return date
 */
function convertStringToDate(dateString)
{
  dateString = dateString.split('-');
  return new Date(dateString[0], dateString[1] - 1, dateString[2]);
}

/**
 * Compute delta of two days.
 *
 * @param  string $date1
 * @param  string $date1
 * @access public
 * @return int
 */
function computeDaysDelta(date1, date2)
{
  date1 = convertStringToDate(date1);
  date2 = convertStringToDate(date2);
  delta = (date2 - date1) / (1000 * 60 * 60 * 24) + 1;

  weekEnds = 0;
  for(i = 0; i < delta; i++)
  {
    if((weekend == 2 && date1.getDay() == 6) || date1.getDay() == 0) weekEnds ++;
    date1 = date1.valueOf();
    date1 += 1000 * 60 * 60 * 24;
    date1 = new Date(date1);
  }
  return delta - weekEnds;
}

/**
 * Compute work days.
 *
 * @access public
 * @return void
 */
function computeWorkDays(currentID)
{
  isBactchEdit = false;
  if(currentID)
  {
    index = currentID.replace('begins[', '');
    index = index.replace('ends[', '');
    index = index.replace(']', '');
    if(!isNaN(index)) isBactchEdit = true;
  }

  if(isBactchEdit)
  {
    beginDate = $('#begins\\[' + index + '\\]').val();
    endDate   = $('#ends\\[' + index + '\\]').val();
  }
  else
  {
    beginDate = $('#begin').val();
    endDate   = $('#end').val();
  }

  if(beginDate && endDate)
  {
    if(isBactchEdit)  $('#dayses\\[' + index + '\\]').val(computeDaysDelta(beginDate, endDate));
    if(!isBactchEdit) $('#days').val(computeDaysDelta(beginDate, endDate));
  }
  else if($('input[checked="true"]').val())
  {
    computeEndDate();
  }
}

/**
 * Compute the end date for project.
 *
 * @param  int    $delta
 * @access public
 * @return void
 */
function computeEndDate(delta)
{
  beginDate = $('#begin').val();
  if(!beginDate) return;

  delta     = parseInt(delta);
  beginDate = convertStringToDate(beginDate);
  if((delta == 7 || delta == 14) && (beginDate.getDay() == 1))
  {
    delta = (weekend == 2) ? (delta - 2) : (delta - 1);
  }

  endDate = beginDate.addDays(delta - 1).toString('yyyy-MM-dd');
  $('#end').val(endDate).datetimepicker('templates.update');
  computeWorkDays();
}

/**
 * Load branches.
 *
 * @param  int $product
 * @access public
 * @return void
 */
function loadBranches(product)
{
  $('#productsBox select').each(function()
  {
    var $product = $(product);
    if($product.val() != 0 && $product.val() == $(this).val() && $product.attr('id') != $(this).attr('id'))
    {
      alert(errorSameProducts);
      $product.val(0);
      $product.trigger("chosen:updated");
      return false;
    }
  });

  if($('#productsBox .input-group:last select:first').val() != 0)
  {
    var length = $('#productsBox .input-group').size();
    $('#productsBox .row').append('<div class="col-sm-4">' + $('#productsBox .col-sm-4:last').html() + '</div>');
    if($('#productsBox .input-group:last select').size() >= 2) $('#productsBox .input-group:last select:last').remove();
    $('#productsBox .input-group:last .chosen-container').remove();
    $('#productsBox .input-group:last select:first').attr('name', 'products[' + length + ']').attr('id', 'products' + length);
    $('#productsBox .input-group:last .chosen').chosen();

    adjustProductBoxMargin();
  }

  var $inputgroup = $(product).closest('.input-group');
  if($inputgroup.find('select').size() >= 2) $inputgroup.removeClass('has-branch').find('select:last').remove();
  if($inputgroup.find('.chosen-container').size() >= 2) $inputgroup.find('.chosen-container:last').remove();

  var index = $inputgroup.find('select:first').attr('id').replace('products' , '');
  $.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val()), function(data)
  {
    if(data)
    {
      $inputgroup.addClass('has-branch').append(data);
      $inputgroup.find('select:last').attr('name', 'branch[' + index + ']').attr('id', 'branch' + index).attr('onchange', "loadPlans('#products" + index + "', this.value)").chosen();
    }
  });

  loadPlans(product);
}

function loadPlans(product, branchID)
{
  if($('#plansBox').size() == 0) return false;

  var productID = $(product).val();
  var branchID  = typeof(branchID) == 'undefined' ? 0 : branchID;
  var index     = $(product).attr('id').replace('products', '');

  if(productID != 0)
  {
    if(typeof(planID) == 'undefined') planID = 0;
    planID = $("select#plans" + productID).val() != '' ? $("select#plans" + productID).val() : planID;
    $.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + '&branch=' + branchID + '&planID=' + planID + '&fieldID&needCreate=&expired=' + ((config.currentMethod == 'create' || config.currentMethod == 'edit') ? 'unexpired' : '')), function(data)
    {
      if(data)
      {
        if($("div#plan" + index).size() == 0) $("#plansBox .row").append('<div class="col-sm-4" id="plan' + index + '"></div>');
        $("div#plan" + index).html(data).find('select').attr('name', 'plans[' + productID + ']').attr('id', 'plans' + productID).chosen();

        adjustPlanBoxMargin();
      }
    });
  }
}


function adjustProductBoxMargin()
{
  var productRows = Math.ceil($('#productsBox > .row > .col-sm-4').length / 3);
  if(productRows > 1)
  {
    for(i = 1; i <= productRows - 1; i++)
    {
      $('#productsBox .col-sm-4:lt(' + (i * 3) + ')').css('margin-bottom', '10px');
    }
  }
}

function adjustPlanBoxMargin()
{
  var planRows = Math.ceil($('#plansBox > .row > .col-sm-4').length / 3);
  if(planRows > 1)
  {
    for(j = 1; j <= planRows - 1; j++)
    {
      $('#plansBox .col-sm-4:lt(' + (j * 3) + ')').css('margin-bottom', '10px');
    }
  }
}

function loadBranch(){}

/* Auto compute the work days. */
$(function()
{
  $(".date").bind('dateSelected', function()
  {
    computeWorkDays(this.id);
  })
});

$(function()
{
  $(document).on('click', '.task-toggle', function(e)
  {
    var $toggle = $(this);
    var id = $(this).data('id');
    var isCollapsed = $toggle.toggleClass('collapsed').hasClass('collapsed');
    $toggle.closest('[data-ride="table"]').find('tr.parent-' + id).toggle(!isCollapsed);

    e.stopPropagation();
    e.preventDefault();
  });

  adjustProductBoxMargin();
  adjustPlanBoxMargin();
});
$(function()
{
  $('#projectTableList').on('sort.sortable', function(e, data)
  {
    var list = '';
    for(i = 0; i < data.list.length; i++) list += $(data.list[i].item).attr('data-id') + ',';
    $.post(createLink('project', 'updateOrder'), {'projects' : list, 'orderBy' : orderBy});
  });
});

function byProduct(productID, projectID, status)
{
  location.href = createLink('project', 'all', "status=" + status + "&project=" + projectID + "&orderBy=" + orderBy + '&productID=' + productID);
}

</script>
</body>
</html>
